package com.lw.mapper;

import com.lw.config.mybatis.page.Page;
import com.lw.config.mybatis.page.PageRequest;
import com.lw.entity.GoodsInfo;
import com.lw.vo.GoodsInfoVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GoodsMapper {

    /**
     * 分页查询
     * @param vo
     * @return
     */
    Page<GoodsInfoVo> findGoodsListByPage(@Param("vo") GoodsInfo vo, PageRequest pageRequest);

    void updateGoodsInfo(@Param("vo") GoodsInfo goodsInfo);
    void addGoodsInfo(@Param("vo") GoodsInfo goodsInfo);

    @Select("select t.*," +
            " date_format(t.create_time,'%Y/%m/%d %H:%i') as create_time_fmt,\n" +
            " date_format(t.update_time,'%Y/%m/%d %H:%i') as update_time_fmt " +
            " from mall_goods t where t.id = #{id}")
    GoodsInfoVo findInfoById(@Param("id")int id);
}
